﻿using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using Padsurface.CoreAudio.Components.WASAPI.Interfaces;
using Padsurface.CoreAudio.Wrappers.Services;
using Padsurface.CoreAudio.Wrappers.Services.Interfaces;
using Padsurface.Tests;
using System.Threading;
using Windows.UI.Xaml;

namespace Padsurface.CoreAudio.Tests.Integration.Wrappers.AudioClientActivatorSpecifications
{
    public abstract class WhenActivate : TestBase
    {
        protected IAudioClientActivator AudioClientActivator { get; private set; }
        protected IAudioClient Result { get; set; }

        protected override void Arrange()
        {
            base.Arrange();

            EventTrigger = new ManualResetEvent(false);
            AudioClientActivator = new AudioClientActivator();
        }

        protected override void Act()
        {
            AudioClientActivator.Activate().ContinueWith(t => 
            {
                Result = t.Result;
                EventTrigger.Set();
            });
        }
    }

    [TestClass]
    public class WhenActivateTest : WhenActivate
    {
        [TestMethod]
        public void ThenResultShouldContainAnIAudioClient()
        {
            Assert.IsNotNull(Result);
        }
    }
}
